<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="TJpgDec" href="../00index.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>TJpgDec - jd_prepare</title>
</head>

<body>

<div class="para func">
<h2>jd_prepare</h2>
<p>The jd_prepare function analyzes the JPEG data and create a decompression object for subsequnet decompression process.</p>
<pre>
JRESULT jd_prepare (
  JDEC* <em>jdec</em>,            <span class="c">/* Pointer to blank decompression object */</span>
  uint16_t(*<em>infunc</em>)(JDEC*,uint8_t*,uint16_t), <span class="c">/* Pointer to input function */</span>
  void* <em>work</em>,            <span class="c">/* Pointer to work area */</span>
  uint16_t <em>sz_work</em>,      <span class="c">/* Size of the work area */</span>
  void* <em>device</em>           <span class="c">/* Device identifier for the session */</span>
);
</pre>
</div>

<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>jdec</dt>
<dd>Specifies the <a href="jdec.html">decompression object</a> to be initialized. The decompression object is used for subsequent decompression process.</dd>
<dt>input</dt>
<dd>Specifies the user defined <a href="input.html">data input function</a>. The jd_prepare and jd_decomp function call this function to read the JPEG data from the input stream.</dd>
<dt>work</dt>
<dd>Specifies pointer to the work area for this session. It should be aligned to word boundary or it can result an exception.</dd>
<dt>sz_work</dt>
<dd>Specifies size of the work area in unit of byte. TJpgDec requires upto 3092 bytes of work area depends on the built-in parameter tables of the JPEG image to deccompress.</dd>
<dt>device</dt>
<dd>Specifies pointer to the user defined device identifier for this session. It is stored to the member <tt>device</tt> in the decompression object. It can be refered by I/O functions to identify the current session. When I/O device is fixed in the project or this feature is not needed, set NULL and do not care about this.</dd>
</dl>
</div>


<div class="para ret">
<h4>Return Values</h4>
<dl class="ret">
<dt>JDR_OK</dt>
<dd>Function succeeded and decompression object is valid.</dd>
<dt>JDR_INP</dt>
<dd>An error occured in input function due to hard error or wrong stream termination.</dd>
<dt>JDR_MEM1</dt>
<dd>Insufficient work area for this JPEG image.</dd>
<dt>JDR_MEM2</dt>
<dd>Insufficient input buffer for this JPEG image. JD_SZBUF may be too small.</dd>
<dt>JDR_PAR</dt>
<dd>Parameter error. Given pointer to the work area is NULL.</dd>
<dt>JDR_FMT1</dt>
<dd>Data format error. The JPEG data can be collapted.</dd>
<dt>JDR_FMT2</dt>
<dd>Right format but not supported. May be a grayscale image.</dd>
<dt>JDR_FMT3</dt>
<dd>Not supported JPEG standard. May be a progressive JPEG image.</dd>
</dl>
</div>

<div class="para desc">
<h4>Description</h4>
<p>The jd_prepare function is the first stage of a JPEG decompression session. It analyzes the JPEG image and create parameter tables for decompression. After the function succeeded, the session gets ready to decompress the JPEG image by the jd_decomp fnction. The application program can refer the dimensions of the JPEG image stored in the decompression object. These information will be used to configure the output device and parameters for subsequent decompression stage.</p>
</div>

<p class="foot"><a href="../00index.html">Return</a></p>
</body>
</html>
